/*****************************************************************************
 * ui_sys_body.h: Copyright 2023 (c) CoreLink
 * Desc:
 *
 * Author: Flying (weekend@111.com)
 * Date: 2023-09-06 18:06:07
 * Notes:
 *
 * ---------------------------------------------------------------------------
 * LastEditors:
 * LastEditTime:
 *****************************************************************************/
#ifndef UI_SYS_BODY_H_
#define UI_SYS_BODY_H_

#ifdef __cplusplus
extern "C"
{
#endif
    /*------------------------------- Includes ----------------------------------*/
#include "my_conf.h"
#include "lvgl.h"
#include "tuya_list.h"

    /*----------------------------- 全局定义 ------------------------------*/
    struct ui_sys_body_info_t_;
    typedef void (*ui_sys_body_event_cb_t)(struct ui_sys_body_info_t_ *info);

    typedef enum SYS_BODY_CODE_E_
    {
        SYS_BODY_CODE_CLICKED,
        SYS_BODY_CODE_SCROLL,
        SYS_BODY_CODE_GESTURE_UP
    } SYS_BODY_CODE_E;

    /*----------------------------- 全局类型 -----------------------------*/
    typedef struct ui_sys_body_info_t_
    {
        int row_max; // 行数
        int col_max; // 列数
        lv_obj_t *parent;
        lv_obj_t *cont;
        lv_style_t page_style;
        LIST_HEAD item_list;
        LIST_HEAD page_list;
        ui_sys_body_event_cb_t event_cb;
        void *cb_arg;

        int sync_page;
        int sync_index;
        SYS_BODY_CODE_E sync_code;
    } ui_sys_body_info_t;
    /*----------------------------- 全局外部变量 --------------------------*/

    /*------------------------ 全局函数原型 -----------------------*/
    ui_sys_body_info_t *ui_sys_body_create(lv_obj_t *parent, ui_sys_body_event_cb_t cb, void *arg);
    int ui_sys_body_show(ui_sys_body_info_t *info);
    int ui_sys_body_delete(ui_sys_body_info_t *info);

    lv_obj_t *ui_sys_body_add_item(ui_sys_body_info_t *info, const lv_img_dsc_t *img_dsc, char *label_text, bool is_draw_line, bool is_enable);
    int ui_sys_body_get_sync_code(ui_sys_body_info_t *info);
    int ui_sys_body_get_sync_index(ui_sys_body_info_t *info);
    void ui_sys_body_select_page(ui_sys_body_info_t *info, int index, lv_anim_enable_t anim_en);
    lv_obj_t *ui_sys_body_get_item_obj(ui_sys_body_info_t *info, int index);

#ifdef __cplusplus
}
#endif
#endif // UI_SYS_BODY_H_
